<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="100px">
            <el-form-item label="产品名称" prop="productName">
                <el-input v-model="queryParams.productName" placeholder="请输入产品名称"
                          clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="客户手机号" prop="customerPhone">
                <el-input v-model="queryParams.customerPhone" placeholder="请输入客户手机号"
                          clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="下单时间">
                <el-date-picker v-model="dateRange" size="small" style="width: 360px" value-format="yyyy-MM-dd HH:mm:ss"
                                type="datetimerange" range-separator="-" :default-time="['00:00:00', '23:59:59']" start-placeholder="开始日期" end-placeholder="结束日期"/>
            </el-form-item>
            <el-form-item label="收益期限">
                <el-date-picker v-model="dateRange1" size="small" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                                type="daterange" range-separator="-" :default-time="['00:00:00', '23:59:59']" start-placeholder="开始日期" end-placeholder="结束日期"/>
            </el-form-item>
            <el-form-item label="状态" prop="status">
                <el-select
                    v-model="queryParams.status"
                    placeholder="请输入状态"
                    clearable
                    size="small"
                    style="width: 240px"
                >
                    <el-option
                        v-for="dict in billStatus"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                    />
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
<!--            <el-col :span="1.5">-->
<!--                <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"-->
<!--                           v-hasPermi="['bs:bill:saveOrUpdate']"-->
<!--                >新增</el-button>-->
<!--            </el-col>-->
            <el-col :span="1.5">
                <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
                        v-hasPermi="['bs:bill:export']"
                >导出</el-button>
            </el-col>
        </el-row>
        <el-table v-loading="loading" :data="configList" @selection-change="handleSelectionChange">
            <el-table-column label="ID" align="center" prop="id" :show-overflow-tooltip="true" />
            <el-table-column label="产品名称" align="center" prop="productName" :show-overflow-tooltip="true" />
            <el-table-column label="客户手机号" align="center" prop="customerPhone" :show-overflow-tooltip="true" />
            <el-table-column label="数量" align="center" prop="billNum" :show-overflow-tooltip="true" />
            <el-table-column label="下单时间" align="center" prop="createTime" width="180" />
            <el-table-column label="签约信息" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <span class="link-type" @click="handleShow(scope.row)">
                        查看合同
                    </span>
                </template>
            </el-table-column>
            <el-table-column label="付款凭证" align="center" prop="payImg" :show-overflow-tooltip="true" >
                <template slot-scope="scope">
                    <span class="link-type" @click="handleShowPayImg(scope.row.payImg)">
                        查看凭证
                    </span>
                </template>
            </el-table-column>
            <el-table-column label="合同版本号" align="center" prop="contractVersion" :show-overflow-tooltip="true" />
            <el-table-column label="收益期限" align="center" width="340" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.incomeBeginTime, '{y}-{m}-{d}') }} - {{ parseTime(scope.row.incomeEndTime, '{y}-{m}-{d}') }}</span>
                </template>
            </el-table-column>
            <el-table-column label="状态" align="center" prop="status" width="100" :formatter="statusFormat"/>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
<!--                    <el-button size="mini" type="text" icon="el-icon-view" @click="handleShow(scope.row)"-->
<!--                            v-hasPermi="['bs:bill:saveOrUpdate']">预览</el-button>-->
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" :disabled="scope.row.status === '6'"
                            v-hasPermi="['bs:bill:saveOrUpdate']">处理订单</el-button>
<!--                    <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"-->
<!--                            v-hasPermi="['bs:bill:delete']">删除</el-button>-->
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total>0" :total="total" :page.sync="queryParams.nowPage" :limit.sync="queryParams.pageSize" @pagination="getPage"/>
        <!-- 查看签约和付款凭证对话框 -->
        <el-dialog :title="title" :visible.sync="showOpen" width="800px"  v-dialog-drag :close-on-click-modal='false'>
            <div class="docx-preview">
                <vue-office-docx :src="docxUrl" />
            </div>
            <div class="docx-preview" v-show="showPayImg">
                <el-image
                    style="width: 600px; height: 600px"
                    :src="docxUrl"
                    v-if="docxUrl"
                    :preview-src-list="[docxUrl]"
                >
                </el-image>
                <span v-else>无</span>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="downHandler(docxUrl)">下载</el-button>
                <el-button @click="cancelShow">关闭</el-button>
            </div>
        </el-dialog>
        <!-- 处理订单对话框 -->
        <el-dialog :title="title" :visible.sync="openDeal" width="800px"  v-dialog-drag :close-on-click-modal='false'>
            <el-form ref="formDeal" :model="formDeal" label-width="120px">
                <el-form-item label="上传付款凭证" prop="payImg" v-show="this.formDeal.status === '1'">
                    <imageUpload v-model="formDeal.payImg" :limit="1" :fileSize="2" />
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm1">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>
        <!-- 添加或修改订单管理对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="800px"  v-dialog-drag :close-on-click-modal='false'>
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-form-item label="收益期限开始" prop="incomeBeginTime">
                    <el-date-picker type="datetime" v-model="form.incomeBeginTime" format="yyyy-MM-dd HH:mm:ss"
                                    value-format="yyyy-MM-dd HH:mm:ss" :style="{width: '100%'}" placeholder="请选择收益期限开始" clearable>
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="下单数" prop="billNum">
                    <el-input v-model="form.billNum" style="width: 450px;"  type="text" placeholder="请输入下单数" />
                </el-form-item>
                <el-form-item label="创建人" prop="createBy">
                    <el-input v-model="form.createBy" style="width: 450px;"  type="text" placeholder="请输入创建人" />
                </el-form-item>
                <el-form-item label="创建时间" prop="createTime">
                    <el-date-picker type="datetime" v-model="form.createTime" format="yyyy-MM-dd HH:mm:ss"
                                    value-format="yyyy-MM-dd HH:mm:ss" :style="{width: '100%'}" placeholder="请选择创建时间" clearable>
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="客户id" prop="customerId">
                    <el-input v-model="form.customerId" style="width: 450px;"  type="text" placeholder="请输入客户id" />
                </el-form-item>
                <el-form-item label="客户手机号" prop="customerPhone">
                    <el-input v-model="form.customerPhone" style="width: 450px;"  type="text" placeholder="请输入客户手机号" />
                </el-form-item>
                <el-form-item label="收益期限结束" prop="incomeEndTime">
                    <el-date-picker type="datetime" v-model="form.incomeEndTime" format="yyyy-MM-dd HH:mm:ss"
                                    value-format="yyyy-MM-dd HH:mm:ss" :style="{width: '100%'}" placeholder="请选择收益期限结束" clearable>
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="付款凭证" prop="payImg">
                    <el-input v-model="form.payImg" style="width: 450px;"  type="text" placeholder="请输入付款凭证" />
                </el-form-item>
                <el-form-item label="产品id" prop="productId">
                    <el-input v-model="form.productId" style="width: 450px;"  type="text" placeholder="请输入产品id" />
                </el-form-item>
                <el-form-item label="产品名称" prop="productName">
                    <el-input v-model="form.productName" style="width: 450px;"  type="text" placeholder="请输入产品名称" />
                </el-form-item>
                <el-form-item label="数量" prop="productNum">
                    <el-input v-model="form.productNum" style="width: 450px;"  type="text" placeholder="请输入数量" />
                </el-form-item>
                <el-form-item label="产品价格" prop="productPrice">
                    <el-input v-model="form.productPrice" style="width: 450px;"  type="text" placeholder="请输入产品价格" />
                </el-form-item>
                <el-form-item label="1已签约待付款/2已付款待开通/3已开通待安装/4已安装待收益/5正在收益中/6已终结收益" prop="status">
                    <el-input v-model="form.status" style="width: 450px;"  type="text" placeholder="请输入1已签约待付款/2已付款待开通/3已开通待安装/4已安装待收益/5正在收益中/6已终结收益" />
                </el-form-item>
                <el-form-item label="更新人" prop="updateBy">
                    <el-input v-model="form.updateBy" style="width: 450px;"  type="text" placeholder="请输入更新人" />
                </el-form-item>
                <el-form-item label="更新时间" prop="updateTime">
                    <el-date-picker type="datetime" v-model="form.updateTime" format="yyyy-MM-dd HH:mm:ss"
                                    value-format="yyyy-MM-dd HH:mm:ss" :style="{width: '100%'}" placeholder="请选择更新时间" clearable>
                    </el-date-picker>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>
        <el-dialog title="处理订单" :visible.sync="openFlag">
            <div>
                <div style="height: 450px; padding: 0 20px 40px 20px;">
                    <el-steps direction="vertical" :active="current">
                        <el-step title="已签约待付款">
                            <div slot="title">
                                <div>{{this.billTemp && this.billTemp.status === '1' ? "已签约待付款" : "已签约已付款"}} <el-button class="ml5" type="primary" size="small" v-show="this.billTemp && this.billTemp.status == '1'" @click="handlePayImg">上传付款凭证</el-button></div>
                                <div>{{this.operTime1}}</div>
                            </div>
                        </el-step>
                        <el-step title="已付款待开通" :active="current">
                            <div slot="title">
                                <div>{{this.billTemp && this.billTemp.status === '2' ? "已付款待开通" : "已开通"}} <el-button class="ml5" type="primary" size="small" v-show="this.billTemp && this.billTemp.status == '2'" @click="handleKT">确认开通</el-button></div>
                                <div>{{this.operTime2}}</div>
                            </div>
                        </el-step>
                        <el-step title="已开通待安装" :active="current">
                            <div slot="title">
                                <div>{{this.billTemp && this.billTemp.status === '3' ? "已开通待安装" : "已安装"}} <el-button class="ml5" type="primary" size="small" v-show="this.billTemp && this.billTemp.status == '3'" @click="handleAZ">确认安装</el-button></div>
                                <div>{{this.operTime3}}</div>
                            </div>
                        </el-step>
                        <el-step title="已安装待收益" :active="current">
                            <div slot="title">
                                <div>已安装待收益
                                    <el-date-picker v-model="dateRange2" size="small" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-" :default-time="['00:00:00', '23:59:59']" start-placeholder="开始日期" end-placeholder="结束日期" v-if="this.billTemp && this.billTemp.status == '4'"/>
                                    <el-button class="ml5" type="primary" size="small" v-show="this.billTemp && this.billTemp.status == '4'" @click="handleSY">确认收益</el-button></div>
                                <div>{{this.operTime4}}</div>
                            </div>
                        </el-step>
                        <el-step title="正在收益中" :active="current">
                            <div slot="title">
                                <div>正在收益中 <el-button class="ml5" type="primary" size="small" v-show="this.billTemp && this.billTemp.status == '5'" @click="handleZZ">终止收益</el-button></div>
                            </div>
                        </el-step>
                    </el-steps>
                </div>
                <div style="text-align: right;">
                    <el-button size="small" @click="openFlag = false">关闭</el-button>
                </div>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import {getBsBillPage,getBsBillById,addOrUpdateBsBill,delBsBill,exportBsBill} from "@/api/project/bsBill/bsBill";
import { parseTime } from "@/utils/ruoyi";
import Dict from "@/views/system/dict";
import imageUpload from '@/components/ImageUpload';
import VueOfficeDocx from '@vue-office/docx'
import '@vue-office/docx/lib/index.css'
import { downFile } from "@/utils/ruoyi";
import {getBsPaymentById} from "@/api/project/bsPayment/bsPayment";

export default {
    name: "bsBill",
    components: {
        Dict,
        imageUpload,
        VueOfficeDocx
    },
    data() {
        return {
            showPayImg: false,
            current: 0,
            billTemp: undefined,
            // 状态节点时间
            operTime1: "",
            operTime2: "",
            operTime3: "",
            operTime4: "",
            openFlag: false,
            docxUrl: '',
            baseImgUrl: process.env.VUE_APP_BASE_API,
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 总条数
            total: 0,
            // 参数表格数据
            configList: [],
            // 弹出层标题
            title: "",
            open: false,// 是否显示修改或增加的弹出层
            openDeal: false,
            // 日期范围
            dateRange: [],
            // 收益期限范围
            dateRange1: [],
            dateRange2: [],
            // 订单状态数据字典
            billStatus: [],
            // 查询参数
            queryParams: {
                nowPage: 1,
                pageSize: 10,
                billNum: undefined,
                createBy: undefined,
                customerId: undefined,
                customerPhone: undefined,
                payImg: undefined,
                productId: undefined,
                productName: undefined,
                productNum: undefined,
                productPrice: undefined,
                status: undefined,
                updateBy: undefined,
            },
            // 表单参数
            form: {},
            formDeal: {},
            showOpen: false,//是否显示查看工作内容弹出层
            showForm: {},
            // 表单校验
            rules: {
                billNum: [
                    {required: true, message: "下单数不能为空", trigger: "blur"}
                ],
                createBy: [
                    {required: true, message: "创建人不能为空", trigger: "blur"}
                ],
                customerId: [
                    {required: true, message: "客户id不能为空", trigger: "blur"}
                ],
                customerPhone: [
                    {required: true, message: "客户手机号不能为空", trigger: "blur"}
                ],
                payImg: [
                    {required: true, message: "付款凭证不能为空", trigger: "blur"}
                ],
                productId: [
                    {required: true, message: "产品id不能为空", trigger: "blur"}
                ],
                productName: [
                    {required: true, message: "产品名称不能为空", trigger: "blur"}
                ],
                productNum: [
                    {required: true, message: "数量不能为空", trigger: "blur"}
                ],
                productPrice: [
                    {required: true, message: "产品价格不能为空", trigger: "blur"}
                ],
                status: [
                    {required: true, message: "1已签约待付款/2已付款待开通/3已开通待安装/4已安装待收益/5正在收益中/6已终结收益不能为空", trigger: "blur"}
                ],
                updateBy: [
                    {required: true, message: "更新人不能为空", trigger: "blur"}
                ],
            },
        };
    },
    created() {
        this.getPage();
        this.getDicts("bill_status").then(response => {
            this.billStatus = response.data;
        });
    },
    methods: {
        downHandler(url) {
            downFile(url, "订单合同")
        },
        /** 查询参数列表 */
        getPage(e) {
            this.loading = true;
            let billNum = this.queryParams.billNum || '';
            let createBy = this.queryParams.createBy || '';
            let customerId = this.queryParams.customerId || '';
            let customerPhone = this.queryParams.customerPhone || '';
            let payImg = this.queryParams.payImg || '';
            let productId = this.queryParams.productId || '';
            let productName = this.queryParams.productName || '';
            let productNum = this.queryParams.productNum || '';
            let productPrice = this.queryParams.productPrice || '';
            let status = this.queryParams.status || '';
            let updateBy = this.queryParams.updateBy || '';
            let time = this.dateRange || '';
            let time1 = this.dateRange1 || '';
            let params = '';
            if (e) {
                params = {
                    billNum: billNum,
                    createBy: createBy,
                    customerId: customerId,
                    customerPhone: customerPhone,
                    payImg: payImg,
                    productId: productId,
                    productName: productName,
                    productNum: productNum,
                    productPrice: productPrice,
                    status: status,
                    updateBy: updateBy,
                    incomeBeginTime: time1[0],
                    incomeEndTime: time1[1],
                    nowPage: e.page,
                    pageSize: e.limit
                }
            } else {
                params = {
                    billNum: billNum,
                    createBy: createBy,
                    customerId: customerId,
                    customerPhone: customerPhone,
                    payImg: payImg,
                    productId: productId,
                    productName: productName,
                    productNum: productNum,
                    productPrice: productPrice,
                    status: status,
                    updateBy: updateBy,
                    incomeBeginTime: time1[0],
                    incomeEndTime: time1[1],
                    nowPage: this.queryParams.nowPage,
                    pageSize: this.queryParams.pageSize
                }
            }
            getBsBillPage(params).then(response => {
                this.configList = response.data.records;
                this.total = response.data.total;
                this.loading = false;
            })
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.openDeal = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.form = {
                incomeBeginTime: undefined,
                billNum: undefined,
                createBy: undefined,
                createTime: undefined,
                customerId: undefined,
                customerPhone: undefined,
                incomeEndTime: undefined,
                payImg: undefined,
                productId: undefined,
                productName: undefined,
                productNum: undefined,
                productPrice: undefined,
                status: undefined,
                updateBy: undefined,
                updateTime: undefined,
            };
            this.showForm = {};
            this.formDeal = {
                payImg: undefined
            };
            this.resetForm("form");
            this.resetForm("showForm");
            this.resetForm("formDeal");
        },
        /** 搜索按钮操作 */
        handleQuery() {
            let billNum = this.queryParams.billNum || '';
            let createBy = this.queryParams.createBy || '';
            let customerId = this.queryParams.customerId || '';
            let customerPhone = this.queryParams.customerPhone || '';
            let payImg = this.queryParams.payImg || '';
            let productId = this.queryParams.productId || '';
            let productName = this.queryParams.productName || '';
            let productNum = this.queryParams.productNum || '';
            let productPrice = this.queryParams.productPrice || '';
            let status = this.queryParams.status || '';
            let updateBy = this.queryParams.updateBy || '';
            let time = this.dateRange || '';
            let time1 = this.dateRange1 || '';
            let params = {
                billNum: billNum,
                createBy: createBy,
                customerId: customerId,
                customerPhone: customerPhone,
                payImg: payImg,
                productId: productId,
                productName: productName,
                productNum: productNum,
                productPrice: productPrice,
                status: status,
                updateBy: updateBy,
                incomeBeginTime: time1[0],
                incomeEndTime: time1[1],
                nowPage: 1,
                pageSize: this.queryParams.pageSize
            };
            getBsBillPage(params).then(res => {
                if (res.code == 200) {
                    this.configList = res.data.records;
                    this.total = res.data.total;
                    this.loading = false;
                }
            })
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = [];
            this.dateRange1 = [];
            this.queryParams.billNum = '';
            this.queryParams.createBy = '';
            this.queryParams.customerId = '';
            this.queryParams.customerPhone = '';
            this.queryParams.payImg = '';
            this.queryParams.productId = '';
            this.queryParams.productName = '';
            this.queryParams.productNum = '';
            this.queryParams.productPrice = '';
            this.queryParams.status = '';
            this.queryParams.updateBy = '';
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.open = true;
            this.title = "添加订单管理信息";
        },
        //多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id);
            this.single = selection.length != 1;
            this.multiple = !selection.length
        },
        /** 查看按钮操作 */
        handleShow(row) {
            this.docxUrl = this.baseImgUrl + row.contractPath;
            this.showPayImg = false;
            this.showOpen = true;
            this.title = "查看合同";
        },
        /** 查看按钮操作 */
        handleShowPayImg(payImg) {
            this.docxUrl = this.baseImgUrl + payImg;
            this.showPayImg = true;
            this.showOpen = true;
            this.title = "查看付款凭证";
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.reset();
            this.operTime1 = "";
            this.operTime2 = "";
            this.operTime3 = "";
            this.operTime4 = "";
            this.billTemp = row;
            if(row.status == "1") {
                this.current = 1;
            } else if(row.status == "2") {
                this.current = 2;
            } else if(row.status == "3") {
                this.current = 3;
            } else if(row.status == "4") {
                this.current = 4;
            } else if(row.status == "5") {
                this.current = 5;
            }
            let dataList = [];
            const id = row.id || '';
            getBsBillById({id}).then(response => {
                dataList = response.data.bsOperRecordList;
                dataList.forEach(e =>{
                    // 1已签约待付款
                    if(row.status == "1") {
                        this.operTime1 = e.createTime;
                    } else if(row.status == "2") { // 2已付款待开通
                        this.operTime1 = e.createTime;
                    } else if(row.status == "3") { // 3已开通待安装
                        if(e.billStatus === "1") {
                            this.operTime1 = e.createTime;
                        } else if(e.billStatus === "2") {
                            this.operTime2 = e.createTime;
                        }
                    } else if(row.status == "4") { // 4已安装待收益
                        if(e.billStatus === "1") {
                            this.operTime1 = e.createTime;
                        } else if(e.billStatus === "2") {
                            this.operTime2 = e.createTime;
                        } else if(e.billStatus === "3") {
                            this.operTime3 = e.createTime;
                        }
                    } else if(row.status == "5") { // 5正在收益中
                        if(e.billStatus === "1") {
                            this.operTime1 = e.createTime;
                        } else if(e.billStatus === "2") {
                            this.operTime2 = e.createTime;
                        } else if(e.billStatus === "3") {
                            this.operTime3 = e.createTime;
                        } else if(e.billStatus === "4") {
                            this.operTime4 = e.createTime;
                        }
                    } else if(row.status == "6") { // 6已终结收益
                        if(e.billStatus === "1") {
                            this.operTime1 = e.createTime;
                        } else if(e.billStatus === "2") {
                            this.operTime2 = e.createTime;
                        } else if(e.billStatus === "3") {
                            this.operTime3 = e.createTime;
                        } else if(e.billStatus === "4") {
                            this.operTime4 = e.createTime;
                        }
                    }
                });
                this.openFlag = true;
                this.title = "打款";
            });
        },
        cancelShow: function () {
            this.showOpen = false;
        },
        /** 提交按钮 */
        submitForm: function () {
            this.$refs["form"].validate(valid => {
                if (valid) {
                    if (this.form.id !== undefined) {
                        addOrUpdateBsBill(this.form).then(res => {
                            if (res.code == 200) {
                                this.msgSuccess("修改成功");
                                this.open = false;
                                this.getPage();
                            } else {
                                this.msgError(res.msg);
                            }
                        })
                    } else {
                        addOrUpdateBsBill(this.form).then(res => {
                            if (res.code == 200) {
                                this.msgSuccess("新增成功");
                                this.open = false;
                                this.getPage();
                            } else {
                                this.msgError(res.msg);
                            }
                        })
                    }
                }
            });
        },
        /** 提交按钮 */
        submitForm1: function () {
            this.$refs["formDeal"].validate(valid => {
                if (valid) {
                    if(this.formDeal.status === '1') {
                        this.formDeal.status = '2';
                    }
                    addOrUpdateBsBill(this.formDeal).then(res => {
                        if (res.code == 200) {
                            this.msgSuccess("开通成功");
                            this.openDeal = false;
                            this.openFlag = false;
                            this.getPage();
                        } else {
                            this.msgError(res.msg);
                        }
                    })
                }
            });
        },
        /** 删除按钮操作 */
        handleDelete(row) {
            const ids = row.id || this.ids;
            this.$confirm('是否确认删除订单管理编号为"' + ids + '"的数据项?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                return delBsBill(ids);
            }).then(() => {
                this.getPage();
                this.msgSuccess("删除成功");
            }).catch(function () {
            });
        },
        /** 导出按钮操作 */
        handleExport() {
            const queryParams = this.queryParams;
            this.$confirm('是否确认导出所有订单管理数据项?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                return exportBsBill(queryParams);
            }).then(res => {
                this.download(res.msg);
            }).catch(function () {
            });
        },
        /**
         * 字典状态转换
         */
        statusFormat(row, column) {
            return this.selectDictLabel(this.billStatus, row.status);
        },
        /** 上传付款凭证 */
        handlePayImg() {
            const id = this.billTemp.id || '';
            getBsBillById({id}).then(response => {
                this.formDeal = response.data;
                this.formDeal.dateRange1 = [];
                this.openDeal = true;
                this.title = "上传付款凭证";
            });
        },
        /** 确认开通 */
        handleKT() {
            const id = this.billTemp.id || '';
            const customerId = this.billTemp.customerId || '';
            this.$confirm('是否确认开通订单?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                const formEdit = {
                    id: id,
                    customerId: customerId,
                    status: "3"
                }
                return addOrUpdateBsBill(formEdit);
            }).then(() => {
                this.openFlag = false;
                this.getPage();
                this.msgSuccess("开通成功");
            }).catch(function () {
            });
        },
        /** 确认安装 */
        handleAZ() {
            const id = this.billTemp.id || '';
            const customerId = this.billTemp.customerId || '';
            this.$confirm('是否确认安装订单?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                const formEdit = {
                    id: id,
                    customerId: customerId,
                    status: "4"
                }
                return addOrUpdateBsBill(formEdit);
            }).then(() => {
                this.openFlag = false;
                this.getPage();
                this.msgSuccess("修改成功");
            }).catch(function () {
            });
        },
        /** 确认收益 */
        handleSY() {
            const id = this.billTemp.id || '';
            const customerId = this.billTemp.customerId || '';
            const formSY = {id: id, customerId: customerId};
            if(this.billTemp.status === '4') {
                formSY.status = '5';
                if(this.dateRange2 != undefined) {
                    formSY.incomeBeginTime = this.dateRange2[0];
                    formSY.incomeEndTime = this.dateRange2[1];
                }
            }
            addOrUpdateBsBill(formSY).then(res => {
                if (res.code == 200) {
                    this.msgSuccess("确认成功");
                    this.openDeal = false;
                    this.openFlag = false;
                    this.getPage();
                } else {
                    this.msgError(res.msg);
                }
            })
        },
        /** 终止收益 */
        handleZZ() {
            const id = this.billTemp.id || '';
            const customerId = this.billTemp.customerId || '';
            this.$confirm('是否确认终止订单收益?', "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(function () {
                let date = new Date();
                console.log(date)
                const formEdit = {
                    id: id,
                    customerId: customerId,
                    status: "6"
                }
                return addOrUpdateBsBill(formEdit);
            }).then(() => {
                this.openFlag = false;
                this.getPage();
                this.msgSuccess("修改成功");
            }).catch(function () {
            });
        },
    }
};
</script>
<style lang="scss">
.docx-preview {
    .docx-wrapper>section.docx {
        box-shadow: none;
    }
    .docx-wrapper {
        background-color: #fff;
    }
}

</style>
